package hot;

/**
 * @author way
 * @create 2025-03-08 22:06
 */
public class _73_setZeroes {
    public void setZeroes(int[][] matrix) {
        int m = matrix.length;
        int n = matrix[0].length;
        int[] mArr = new int[m];
        int[] nArr = new int[n];

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (matrix[i][j] == 0) {
                    mArr[i] = 0;
                    nArr[j] = 0;
                }
            }
        }

        for (int i = 0; i < mArr.length; i++) {
            if (mArr[i] == 0) {
                for (int j = 0; j < n; j++) {
                    matrix[i][j] = 0;
                }

            }
        }

        for (int i = 0; i < nArr.length; i++) {
            if (nArr[i] == 0){
                for (int j = 0; j < m; j++) {
                    matrix[i][j] =0;
                }
            }
        }
    }
}
